package homework;

public class Test {
    public static int count = 0;

    public static void main(String[] args) {
        System.out.println(fib(40));
        System.out.println(count);
    }

    //    public static int fib(int n) {
//        if (n == 1 || n == 2) {
//            return 1;
//        }
//        if (n == 3) {
//            count++;
//        }
//        return fib(n - 1) + fib(n - 2);
//    }
    public static int fib(int n) {
        int last2 = 1;
        int last1 = 1;
        int cur = 0;
        for (int i = 3; i <= n; i++) {
            cur = last1 + last2;
            last2 = last1;
            last1 = cur;
        }
        return cur;
    }

}
